/*
 * 
 *
 *
 */
package com.hboxs.asl.service;

import com.hboxs.asl.Page;
import com.hboxs.asl.Pageable;
import com.hboxs.asl.entity.CourseTrade;
import com.hboxs.asl.entity.Member;
import com.pingplusplus.model.Charge;

/**
 * Service - 课程流水
 */
public interface CourseTradeService extends BaseService<CourseTrade, Long> {

    /**
     * 处理支付
     *
     * @param charge ping++charge对象
     * @param courseTrade  订单
     */
    void dealCourseTrade(Charge charge, CourseTrade courseTrade);

    /**
     * 积分处理支付
     *
     * @param courseTrade  订单
     */
    void dealCourseTradeByPoint( CourseTrade courseTrade);

    /**
     * 根据编号查找
     * @param sn(忽略大小写)
     * @return
     */
    CourseTrade findBySn(String sn);

    /**
     * 获取所有账单
     * @param member
     * @param paymentStatus
     * @return
     */
    Page<CourseTrade> allTrade(Pageable pageable, Member member,CourseTrade.PaymentStatus paymentStatus);

    /**
     * 获取所有交易完成的账单
     * @param member
     * @param courseType
     * @param paymentStatus
     * @return
     */
    Page<CourseTrade> all(Pageable pageable, Member member, CourseTrade.CourseType courseType, CourseTrade.PaymentStatus paymentStatus);

    /**
     * 获取所有正在进行的账单
     * @param member
     * @param courseType
     * @param paymentStatus
     * @return
     */
    Page<CourseTrade> ing(Pageable pageable, Member member, CourseTrade.CourseType courseType, CourseTrade.PaymentStatus paymentStatus);

    /**
     * 获取所有待评价的账单
     * @param member
     * @param courseType
     * @param paymentStatus
     * @return
     */
    Page<CourseTrade> toEvaluate(Pageable pageable, Member member, CourseTrade.CourseType courseType, CourseTrade.PaymentStatus paymentStatus, Boolean hasReview);

    /**
     * 判断用户是否购买课程情况
     * @param courseId
     * @param buyer
     * @param paymentStatus
     * @return
     */
    long findPaidCourse(Long courseId, Member buyer, CourseTrade.PaymentStatus paymentStatus);

    /**
     * 已购买视频
     * @param pageable
     * @param buyer
     * @param paymentStatus
     * @return
     */
    Page<CourseTrade> findPaidCourseTrades(Pageable pageable, Member buyer, CourseTrade.PaymentStatus paymentStatus, Long categoryId);

    long getCourseTradeCount(CourseTrade.PaymentStatus paymentStatus);

    CourseTrade courseTradeCount(CourseTrade.PaymentStatus paymentStatus, Member member, Long courseId);

    /**
     * 批量修改课程状态
     * @param courseId
     */
    void updateBatch(Long courseId, CourseTrade.CourseType courseType);

}
